#include <stdio.h>
#include <omp.h>

void compute(float **row, int i, int j) {
    row[i][j] = row[i-1][j] + row[i][j-1];  // 模拟依赖
}

void kernel(int N, float **row) {
    #pragma omp parallel for collapse(2) ordered(2)
    for (int i = 1; i < N; i++) {
        for (int j = 1; j < N; j++) {
            #pragma omp ordered doacross(sink: i-1, j)   // 等待上方
            #pragma omp ordered doacross(sink: i, j-1)   // 等待左侧
            compute(row, i, j);

            #pragma omp ordered doacross(source: omp_cur_iteration)
        }
    }
}
